var app = getApp();
//
Page({
  data: {
    project:{},
    date:[],
    img_src:app.img_src,
    inputValue:'',
    _cat:true,
    item:{},
    toast:false,
    text:'',
    crmItemList:[]
  },
  onLoad: function (e) {
    var t = this;
    getApp().page.onLoad(t, e);
    app.bus.onLoad(t);
    t.getText()
  },
  getText(){
    var that = this;
    app.request({
      url:getApp().api.siteinfo.apiroot+'action/getReserveInfo',
      success:function (e) {
        e.result == 0 && that.setData({text:e.text})
      }
    })
  },
  setCat(){
    this.setData({_cat:!this.data._cat})
  },

  bindinput(e){
    this.data.inputValue = e.detail.value
  },
  sub(){
    this.data.item.id && this.setData({toast:!this.data.toast})
  },
  formSubmit(){
    var t = this, d = t.data,
      customerId = wx.getStorageSync('customerId');
    app.request({
      url:'https://live.sgwxmini.com/beauty/rowNumber/saveYY',
      data:{
        hosId:app.api.siteinfo.hosId,
        itemId:d.item.item_id,
        itemDetailId:d.item.id,
        yyTimeBegin:d.item.s,
        yyTimeEnd:d.item.e,
        customerId:customerId,
        memo:d.inputValue,
        drive:d._cat?1:0
      },
      success(e){
        console.log(e)
        e.result == 0 ? t.setData({
          toast:false
        },function () {
          t.setData({crmItemList:[],item:{}})
          wx.navigateTo({
            url:'/pages/yuyue2/order/order?id='+e.data.id+'&h='+app.api.siteinfo.hosId+'&u='+app.customerId
          })
        }):wx.showToast({icon:'none',title:e.message})
      }
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})